*** Pgm Location: Vietnam - HCM Clinic
*** -----------------------------------------------------------
*** Change History log:
**  Chg request #001.
**  Chg request Date:25-11-2001; requested by: Simon
**  Chg request Descriptions:
**      to hardcode for the TRI CARE program to automatically add 10% to the public price of the 
**      procedure items and ignore/exclude the 10% service tax for this pgm
**      Pgm affected:  cash1.prg, cashdpat.prg, prtivwf.prg,cashprin.prg
** --------------------------------------------------------------
**  Chg request #002.
**  Chg request Descriptions:
**      don't hard code the service fees value - now set in the aeacopr.comp_srv field 
** --------------------------------------------------------------

***
***                                                                                                                                                                                                                                                       
*** This Program already converted to Y2K                                                                                                                                                                                                                 
*** S&T Departement     on 29 April 1999 by Ben.Rahman                                                                                                                                                                                                    
***                                                                                                                                                                                                                                                       
***                                                                                                                                                                                                                                                       
set cent on                                                                                                                                                                                                                                               
* FILE NAME : PRTIVWF.PRG                                                                                                                                                                                                                                 
*                                                                                                                                                                                                                                                         
SET CENT ON
Set Printer to PRN                                                                                                                                                                                                                                        
Set print on                                                                                                                                                                                                                                              
set device to printer                                                                                                                                                                                                                                     
setprc(0,0)                                                                                                                                                                                                                                               
  

**STORE 0 TO TOTMED,TOTPHR,TOTALL,tax,totwtax,gtotmed,gtotphr,PUBLIC_P
STORE 0 TO TOTMED,TOTPHR,TOTALL,totwtax,gtotmed,gtotphr,PUBLIC_P,TOTFAK
**
page = 0                                                                                                                                                                                                                                                  
a=str(year(date()),4)
** a=substr(str(a,4),3,2)                                                                                                                                                                                                                                    

mstop = .f.
phar_flag = .f. 
pzp9_flag = .f.
STORE 0 TO pzp9_price
STORE SPACE(25) TO shrt_dscp9                                                                                                                                                                                                                                              
BB = 3                                                                                                                                                                                                                                                    
AA = 2                                                                                                                                                                                                                                                    
SELE 3                                                                                                                                                                                                                                                    
f3='\temp\ph'+kdpat                                                                                                                                                                                                                                             
use &dr&f3                                                                                                                                                                                                                                                
n2=reccount()                                                                                                                                                                                                                                             
l2 = reccount()/12                                                                                                                                                                                                                                        
lx2= int(l2)                                                                                                                                                                                                                                              
GO TOP                                                                                                                                                                                                                                                    
SELE 2                                                                                                                                                                                                                                                    
n1=reccount()                                                                                                                                                                                                                                             
l1 = reccount()/10                                                                                                                                                                                                                                        
lx1= int(l1)                                                                                                                                                                                                                                              
GO TOP                                                                                                                                                                                                                                                    
if l1 > l2                                                                                                                                                                                                                                                
	IF LX1 = 0                                                                                                                                                                                                                                             
		tot_pg = 1                                                                                                                                                                                                                                          
	ELSE                                                                                                                                                                                                                                                   
      	if MOD(n1,10)#0                                                                                                                                                                                                                                     
	 		tot_pg = lx1+1                                                                                                                                                                                                                                          
      	else                                                                                                                                                                                                                                                
	 		tot_pg = lx1                                                                                                                                                                                                                                            
      	endif                                                                                                                                                                                                                                               
   	ENDIF                                                                                                                                                                                                                                                  
else                                                                                                                                                                                                                                                      
   	IF LX2 = 0                                                                                                                                                                                                                                             
      	tot_pg = 1                                                                                                                                                                                                                                          
   	ELSE                                                                                                                                                                                                                                                   
      	if MOD(n2,12)#0                                                                                                                                                                                                                                     
	 		tot_pg = lx2+1                                                                                                                                                                                                                                          
      	else                                                                                                                                                                                                                                                
	 		tot_pg = lx2                                                                                                                                                                                                                                            
      	endif                                                                                                                                                                                                                                               
   	ENDIF                                                                                                                                                                                                                                                  
endif                                                                                                                                                                                                                                                     
CT=0                                                                                                                                                                                                                                                      
DO While !mstop                                                                                                                                                                                                                                           
	CT=CT+1                                                                                                                                                                                                                                                
   	nCntr = 0                                                                                                                                                                                                                                              
   	F6 = 'CTRPRN'                                                                                                                                                                                                                                          
   	SELE 6                                                                                                                                                                                                                                                 
   	SET EXCLU OFF                                                                                                                                                                                                                                          
   	USE &DR&F6                                                                                                                                                                                                                                             
   	nCntr = CNTR+1
**
**
   	IF nCntr > 99999
		nCntr = 1
   	Endif
**
**
   	IF Rec_LOCK()
      	REPL CNTR WITH nCntr                                                                                                                                                                                                                                
   	ENDIF                                                                                                                                                                                                                                                  
   	SELE 3                                                                                                                                                                                                                                                 
   	IF CT=1                                                                                                                                                                                                                                                
    	DO CASE                                                                                                                                                                                                                                             
      	CASE NCNTR<10                                                                                                                                                                                                                                       
	 		NOFT='0000'+STR(NCNTR,1)                                                                                                                                                                                                                                
      	CASE NCNTR<100                                                                                                                                                                                                                                      
	 		NOFT= '000'+STR(NCNTR,2)                                                                                                                                                                                                                                
      	CASE NCNTR<1000                                                                                                                                                                                                                                     
	 		NOFT='00'+STR(NCNTR,3)                                                                                                                                                                                                                                  
      	case Ncntr<10000                                                                                                                                                                                                                                    
	 		NOFT='0'+STR(NCNTR,4)                                                                                                                                                                                                                                   
      	OTHER                                                                                                                                                                                                                                               
	 		noft=str(Ncntr,5)                                                                                                                                                                                                                                 
      	ENDCASE                                                                                                                                                                                                                                             
   	ENDIF                                                                                                                                                                                                                                                  
   	mstop = .t.                                                                                                                                                                                                                                            
   	do HEAD1                                                                                                                                                                                                                                               
   	BR=22                                                                                                                                                                                                                                                  
   	SELECT 2                                                                                                                                                                                                                                               
   	DO WHILE !EOF()                                                                                                                                                                                                                                        
    	IF BR> 32                                                                                                                                                                                                                                           
	 		MSTOP=.F.                                                                                                                                                                                                                                               
	 		EXIT                                                                                                                                                                                                                                                    
      	ENDIF                                                                                                                                                                                                                                               
      	KDSH=AREA_CODE+SUB_AREACO+PRO_CODE
      	* Use PZP9 for Pharmacy Services
      	* Added by Thien on Thursday, 14 May 2009
      	* Process normal for those are not PZP9		        	
     	* Turn on pzp9_flag
      	* Get the Price to pzp9_price      	
		  IF KDSH='PZP9'
		  pzp9_flag=.t.
		  pzp9_price=PROC_PAY
		  shrt_dscp9 = SHRT_DESCR
		  ELSE
      	@ BR,3 SAY KDSH                                                                                                                                                                                                                                     
      	@ BR,10 SAY SHRT_DESCR                                                                                                                                                                                                                              
      	IF AREA_CODE<>'E'                                                                                                                                                                                                                                   
	 		@ BR,40 SAY DOC_CODE                                                                                                                                                                                                                             
	 		@ BR,45 SAY DOC_ALIAS                                                                                                                                                                                                                            
      	ENDIF                                                                                                                                                                                                                                               
      	@ BR,55 SAY PROC_X                                                                                                                                                                                                                                  
** PUBLIC_P=PUB_PRICE  
   
      	PROPAY=PROC_PAY
      	PUBLIC_P=PROC_PAY/PROC_X 
                                                                                                                                                                                                                                     
      	DO SAYG WITH BR,58,PUBLIC_P,'99,999,999','99,999,999'                                                                                                                                                                                                  
*      @ BR,59 SAY PUB_PRICE                                                                                                                                                                                                                              
                                                                                                                                                                                                                                           
      	DO SAYG WITH BR,69,PROPAY,'99,999,999','99,999,999'                                                                                                                                                                                                   
      	TOTMED=TOTMED+PROC_PAY                                                                                                                                                                                                                              
      	TOTALL=TOTALL+PROC_PAY
      	ENDIF
      	SELECT 2                                                                                                                                                                                                                                            
      	SKIP                                                                                                                                                                                                                                                
      	BR=BR+1                                                                                                                                                                                                                                             
   	ENDDO                                                                                                                                                                                                                                                  

** chg #001 - start - no service tax for TRI CARE patients
**   IF ALLTRIM(PRGNM) = "TRICARE"
**     serv = 0
**   ELSE
** chg #002 - start - don't hard code the Service Tax fees
**     serv=totmed*10/100
	serv=totmed* (cComp_Srv/100)

**   ENDIF
**

** Buu (14/06/2004): Print Diagnosis Code & Name																															  
   IF PRTDIAG                                                                                                                                                                                                                                            
      @ 34,3 SAY '(ICD-9: '+ DIAG +')'                                                                                                                                                                                                 
   ENDIF                            
** Buu (14/06/2004): End   

   gtotmed=totmed+serv

   DO SAYG WITH 34,69,totmed,'99,999,999','99,999,999'                                                                                                                                                                                                      
   DO SAYG WITH 35,69,serv,'99,999,999','99,999,999'                                                                                                                                                                                                        
   DO SAYG WITH 36,69,gtotmed,'99,999,999','99,999,999'                                                                                                                                                                                                     
   BR=41                                                                                                                                                                                                                                                  
   SELECT 3
   IF .NOT. EOF()
   	phar_flag = .t.
   ENDIF                                                                                                                                                                                                                                               
   DO WHILE !EOF()                                                                                                                                                                                                                                        
*      IF BR>52                                                                                                                                                                                                                                            
*	 SELE 3                                                                                                                                                                                                                                                  
*	 MSTOP=.F.                                                                                                                                                                                                                                               
*	 EXIT                                                                                                                                                                                                                                                    
*      ENDIF                                                                                                                                                                                                                                               
																															  
      KDTEMP=PHAR_CODE                                                                                                                                                                                                                                    
      PAYTMP=PHAR_PAY                                                                                                                                                                                                                                     
      XTEM=PHAR_X     
      PHAPAY=PHAR_PAY	
** -- REM by Thien on 31 MAR 2009 -- Begin --
* Do not need to print out pharmacy items in the invoice any more                                                                                                                                                                                                                                    
*      @ BR,3 SAY KDTEMP                                                                                                                                                                                                                                   
*      @ BR,10 SAY RTRIM(PHAR_NAME)+' '+RTRIM(PHAR_TYPE)+' '+rtrim(PHAR_QANT)                                                                                                                                                                              
*      @ br,44 say PHAR_UNIT                                                                                                                                                                                                                               
*      @ BR,52 SAY PHAR_X                                                                                                                                                                                                                                  
*      @ BR,55 SAY PHAR_PAY/PHAR_X                                                                                                                                                                                                                              
                                                                                                                                                                                                                                           
*      DO SAYG WITH BR,71,PHAPAY,'99,999.99','9,999,999'                                                                                                                                                                                                   
*      F9='DRUGS'                                                                                                                                                                                                                                          
*      SELECT 9                                                                                                                                                                                                                                            
*      SET EXCLUSIVE OFF                                                                                                                                                                                                                                   
*      USE &DR&F9 INDEX &DR&F9                                                                                                                                                                                                                             
*      SEEK KDTEMP                                                                                                                                                                                                                                         
*      IF .NOT. EOF()                                                                                                                                                                                                                                      
*	 IF FOUND()                                                                                                                                                                                                                                       
*	 IF Rec_LOCK(0)                                                                                                                                                                                                                                   
*	    REPL ST_ACT_TOT WITH ST_ACT_TOT-XTEM                                                                                                                                                                                                                 
*	    REPL ST_ACT_BUY WITH INT(ST_ACT_TOT/BUY_SELL_R)                                                                                                                                                                                                      
*	    REPL ST_ACT_SEL WITH ST_ACT_TOT-(ST_ACT_BUY*BUY_SELL_R)                                                                                                                                                                                              
*	 ENDIF                                                                                                                                                                                                                                                   
*	 UNLOCK                                                                                                                                                                                                                                                  
*	 ENDIF                                                                                                                                                                                                                                            
*     ELSE                                                                                                                                                                                                                                                
*	 F10='DISPOS'                                                                                                                                                                                                                                            
*	 SELECT 10                                                                                                                                                                                                                                        
*	 SET EXCLUSIVE OFF                                                                                                                                                                                                                                
*	 USE &DR&F10 INDE &DR&F10                                                                                                                                                                                                                                
*	 SEEK KDTEMP                                                                                                                                                                                                                                             
*	 IF .NOT. EOF()                                                                                                                                                                                                                                          
*	   IF FOUND()                                                                                                                                                                                                                                     
*	   IF Rec_LOCK(0)                                                                                                                                                                                                                                 
*	      REPL ST_ACT_TOT WITH ST_ACT_TOT-XTEM                                                                                                                                                                                                               
*	      REPL ST_ACT_BUY WITH INT(ST_ACT_TOT/BUY_SELL_R)                                                                                                                                                                                                    
*	      REPL ST_ACT_SEL WITH ST_ACT_TOT-(ST_ACT_BUY*BUY_SELL_R)                                                                                                                                                                                            
*	   ENDIF                                                                                                                                                                                                                                                 
*	   UNLOCK                                                                                                                                                                                                                                                
*	   ENDIF                                                                                                                                                                                                                                          
*	 ENDIF                                                                                                                                                                                                                                                   
*     ENDIF                                                                                                                                                                                                                                               
      F10='DISPOS'
        SELECT 10
        SET EXCLUSIVE OFF
        USE &DR&F10 INDE &DR&F10
        SEEK KDTEMP
        IF .NOT. EOF()
          IF FOUND()
            IF FOR_SOS
              TOTFAK = TOTFAK+PAYTMP
            ENDIF
            IF Rec_LOCK(0)
              REPL ST_ACT_TOT WITH ST_ACT_TOT-XTEM
              REPL ST_ACT_BUY WITH INT(ST_ACT_TOT/BUY_SELL_R)
              REPL ST_ACT_SEL WITH ST_ACT_TOT-(ST_ACT_BUY*BUY_SELL_R)
            ENDIF
            UNLOCK
          ENDIF
        ENDIF
      TOTPHR=TOTPHR+PAYTMP                                                                                                                                                                                                                                
      TOTALL=TOTALL+PAYTMP                                                                                                                                                                                                                                
      SELECT 3                                                                                                                                                                                                                                            
      SKIP                                                                                                                                                                                                                                                
      **BR=BR+1                                                                                                                                                                                                                                             
   ENDDO
****Thien 08-Nov-2010 : For fak selling...
	 *** Pharmacy services only (w/o FAK)
	PAYTMP = TOTFAK - TOTPHR
  if PAYTMP = 0
    phar_flag = .F.
  endif	 
	if phar_flag .and. pzp9_flag=.f.         
		@ BR,10 SAY "PHARMACY SERVICES"
		PAYTMP = TOTPHR - TOTFAK
*		DO SAYG WITH BR,69,TOTPHR,'99,999,999','99,999,999'
	 DO SAYG WITH BR,69,PAYTMP,'99,999,999','99,999,999'
	endif
	if pzp9_flag
		@ BR,10 SAY RTRIM(shrt_dscp9)
		TOTPHR=pzp9_price
		DO SAYG WITH BR,69,TOTPHR,'99,999,999','99,999,999'
	endif
	BR = BR + 1
	if TOTFAK > 0
	sele 3
	go top
  DO WHILE !EOF()
    IF BR>52
      SELE 3
      MSTOP=.F.
      EXIT
    ENDIF
    KDTEMP=PHAR_CODE
    F10='DISPOS'
    SELECT 10
    SET EXCLUSIVE OFF
    USE &DR&F10 INDE &DR&F10
    SEEK KDTEMP
    IF FOUND()
      IF FOR_SOS
        SELE 3
        @ BR,3 SAY KDTEMP
        @ BR,10 SAY RTRIM(PHAR_NAME)+' '+RTRIM(PHAR_TYPE)+' '+rtrim(PHAR_QANT)
        @ br,44 say PHAR_UNIT
        @ BR,52 SAY PHAR_X
        *@ BR,55 SAY PHAR_PAY/PHAR_X
        PHAPAY = PHAR_PAY/PHAR_X
        DO SAYG WITH BR,58,PHAPAY,'99,999,999','99,999,999'
        PHAPAY = PHAR_PAY
        DO SAYG WITH BR,69,PHAPAY,'99,999,999','99,999,999'        
      ENDIF
    ENDIF
    SELE 3
    SKIP
    BR = BR + 1
	ENDDO
	endif
	*endif - TOTFAK > 0
****End Thien
*********************************************************************
** THIEN added on 31/Jul/2009 to print sentences		   **
** For Corporate Direct Billing and Corporate Credit Patient	   **
** Created WORD_DIS table to store sentences			   **
*********************************************************************
	IF paymode='DIRECT' .OR. paymode='CCP' .OR. paymode='DIRECTB'
*		BR = 52
		F4 = 'WORD_DIS'
		SELE 4
		USE &DR&F4
		DO WHILE !EOF()
* .AND. BR < 56
			@ WORD_ROW, WORD_COL SAY TRIM(WORD_DESC)
			SELE 4
			SKIP
*			BR = BR + 1
		ENDDO
	ENDIF  
***************      
** END THIEN **
***************                                                                                                                                                                                                                               
   nvat=totphr*vat/100                                                                                                                                                                                                                                    
   gtotphr=totphr+nvat                                                                                                                                                                                                                                    
   grtotal=gtotmed+gtotphr               

   DO SAYG WITH 55,69,totphr,'99,999,999','99,999,999'                                                                                                                                                                                                      
   @ 56,23 say vat                                                                                                                                                                                                                                        
   DO SAYG WITH 56,69,nvat,'99,999,999','99,999,999'                                                                                                                                                                                                        
   DO SAYG WITH 57,69,gtotphr,'99,999,999','99,999,999'                                                                                                                                                                                                     
   @ 59,64  SAY AEACURR                                                                                                                                                                                                                                   
   DO SAYG WITH 59,69,grtotal,'99,999,999','99,999,999'                                                                                                                                                                                                     
*  Buu : print total VND for each page                                                                                                                                                                                                                    
																															  
   TEMP=0                                                                                                                                                                                                                                                 
   TEMP=gtotmed+gtotphr                                                                                                                                                                                                                                   
   TEMPC=STR(TEMP)+XOPER+STR(XRATE)                                                                                                                                                                                                                       
   TOTTEMP=&TEMPC                                                                                                                                                                                                                                         
   TOTALR=ROUND(TOTTEMP,2)                                                                                                                                                                                                                                 
*** Thien unmarked to print USD for all PM on 05/Nov/2010
***	IF paymode='DIRECT' .OR. paymode='DIRECTB' .OR. paymode='AC GTEE' .OR. paymode='CARD'
* Buu : Print exchange rate 15/05/2003
		@ 60,34 say "Ex. Rate:"
		DO SAYG WITH 60,45,xrate,'99,999.99','99,999,999'                                                                                                                                                                                                     
* Buu : End print exchange Rate
																															  
*  Buu end print total VND for each page                                                                                                                                                                                                                  
																															  
		@ 60,64  SAY AEABCUR                                                                                                                                                                                                                                   
*		DO SAYG WITH 60,69,TOTAL,'999,999,999','999,999,999'                                                                                                                                                                                                   
*		DO SAYG WITH 60,69,grtotlcd,'99,999.99','99,999.99'                                                                                                                                                                                               
	    DO SAYG WITH 60,69,TOTALR,'99,999.99','99,999.99'
***    ENDIF
*** End Thien
   if !mstop                                                                                                                                                                                                                                              
      DO EJECT                                                                                                                                                                                                                                            
      loop                                                                                                                                                                                                                                                
   endif                                                                                                                                                                                                                                                  
																															  
*   @ 50,10  SAY AEACURR                                                                                                                                                                                                                                  
*   DO SAYG WITH 50,14,TOTMED,'99,999.99','9,999,999'                                                                                                                                                                                                     
*   @ 50,38 SAY aeacurr                                                                                                                                                                                                                                   
*   DO SAYG WITH 50,44,TOTPHR,'99,999.99','9,999,999'                                                                                                                                                                                                     
*   @ 50,63 SAY aeacurr                                                                                                                                                                                                                                   
*   DO SAYG WITH 50,70,TOTALL,'99,999.99','9,999,999'                                                                                                                                                                                                     
*   @ 51,49 SAY '10% SERVICES '                                                                                                                                                                                                                           
*   @ 51,63 SAY aeacurr                                                                                                                                                                                                                                   
*   tax = TOTALL / 10                                                                                                                                                                                                                                     
*   DO SAYG WITH 51,70,tax,'99,999.99','9,999,999'                                                                                                                                                                                                        
*   @ 52,50 SAY 'GRAND TOTAL  '                                                                                                                                                                                                                           
*   @ 52,63 SAY aeacurr                                                                                                                                                                                                                                   
*   totwtax = TOTALL + tax                                                                                                                                                                                                                                
*   DO SAYG WITH 52,70,totwtax,'99,999.99','9,999,999'                                                                                                                                                                                                    
																															  
*   @ 53,63  SAY AEABCUR                                                                                                                                                                                                                                  
*   DO SAYG WITH 53,70,totwlcd,'9,999,999','9,999,999'                                                                                                                                                                                                    
																															  
   BR = 65                                                                                                                                                                                                                                                
   cl = 2                                                                                                                                                                                                                                                 
   cl2 = 25                                                                                                                                                                                                                                               
   cl3 = 37                                                                                                                                                                                                                                               
																															  
*   IF TOTALL = 0                                                                                                                                                                                                                                         
*      do No_charge                                                                                                                                                                                                                                       
*   Else                                                                                                                                                                                                                                                  
*      do Charge                                                                                                                                                                                                                                          
*   Endif                                                                                                                                                                                                                                                 
																															  
ENDDO                                                                                                                                                                                                                                                     
EJECT                                                                                                                                                                                                                                                     
SET DEVI TO SCREE                                                                                                                                                                                                                                         
																															  
																															  
Procedure No_charge                                                                                                                                                                                                                                       
*------------------                                                                                                                                                                                                                                       
IF HEALTH=.T.                                                                                                                                                                                                                                             
   @ BR, 25   SAY "CORPORATE MEDICAL PLAN PLUS"                                                                                                                                                                                                           
   do DECL_MD                                                                                                                                                                                                                                             
   BR = 61                                                                                                                                                                                                                                                
   @ BR, CL  SAY "The cost of this treatment is entirely borne by CMP PLUS, a prepaid"                                                                                                                                                                    
   @ BR+1,CL SAY "medical care program offered by "+alltrim(AEANAME)                                                                                                                                                                                      
ENDIF                                                                                                                                                                                                                                                     
IF PILC=9                                                                                                                                                                                                                                                 
   @ BR, 25  SAY "       NO CHARGE FORM        "                                                                                                                                                                                                          
   do DECL_MD                                                                                                                                                                                                                                             
   BR = 60                                                                                                                                                                                                                                                
   @ BR, cl SAY "The cost of this treatment is entirely borne by"                                                                                                                                                                                         
   @ BR, cl say AEANAME +"."                                                                                                                                                                                                                              
endif                                                                                                                                                                                                                                                     
																															  
																															  
Procedure Charge                                                                                                                                                                                                                                          
*---------------                                                                                                                                                                                                                                          
DO CASE                                                                                                                                                                                                                                                   
   CASE PMODE=1                                                                                                                                                                                                                                           
      @ BR,   25   SAY "      PAYMENT RECEIPT        "                                                                                                                                                                                                    
      do DECL_MD                                                                                                                                                                                                                                          
      BR = 58                                                                                                                                                                                                                                             
      if PCURRY=1                                                                                                                                                                                                                                         
	 @ br,cl say "Paid, the sum of : "+aeacurr+" "+trans(totwtax,'##,###.##')+" ("+otcur+" "+trans(totwlcd,'##,###,###')+") "+"by : "+paymode                                                                                                         
      else                                                                                                                                                                                                                                                
	 @ br,cl say "Paid, the sum of : "+otcur+' '+trans(totwlcd,'##,###,###')+' ('+aeacurr+' '+trans(totwtax,'##,###.##')+') '+'by : '+paymode                                                                                                         
      endif                                                                                                                                                                                                                                               
																															  
   CASE PMODE=3                                                                                                                                                                                                                                           
      @  BR,   25  SAY "      CREDIT VOUCHER       "                                                                                                                                                                                                      
	do DECL_MD                                                                                                                                                                                                                                               
	BR = 58                                                                                                                                                                                                                                           
	CL = 3                                                                                                                                                                                                                                                   
	IF AUTHOR<>SPACE(16)                                                                                                                                                                                                                              
	   @ BR,CL SAY "CREDIT AUTHORIZED BY : "+AUTHOR PICT "@!"                                                                                                                                                                                         
	   BR=BR+1                                                                                                                                                                                                                                        
	ENDIF                                                                                                                                                                                                                                             
	@ BR,CL SAY "The amount payable to the Clinic for this treatment is  : "+AEACURR                                                                                                                                                                  
	DO SAYG WITH BR,66,totwtax,'999,999.99','99,999,999'                                                                                                                                                                                              
	@  60,  3  SAY "Invoice to : _____________________________________ Tel : ________________"                                                                                                                                                        
	@  61,  3  SAY "Company : _______________________________________________________________"                                                                                                                                                        
	@  62,  3  SAY "Address : _______________________________________________________________"                                                                                                                                                        
	@  63,  3  say "          ________________________________________ Tel : ________________"                                                                                                                                                        
	@  64,  3  SAY "to the attention of : ________________________(Name of Authorized Person)"                                                                                                                                                        
ENDCASE                                                                                                                                                                                                                                                   
																															  
																															  
Procedure HEAD1                                                                                                                                                                                                                                           
*----------------                                                                                                                                                                                                                                         
																															  
page=page+1                                                                                                                                                                                                                                               
@  2, 66  SAY  a+'/'+str(MONTH(DATE()),2)+'/'+NOFT                                                                                                                                                                                                        
@  3, 73  SAY str(page,1) + '/' + str(tot_pg,1)                                                                                                                                                                                                           
@  6, 12  SAY DATE()
@  8, 12  SAY TIME()
@  11, 13  SAY NMPAT                                                                                                                                                                                                                                      
@  11, 38  SAY FNMPAT                                                                                                                                                                                                                                     
@  11, 70  SAY KDPAT
																															  
age=round((date()-dobpat)/365,0)

IF AGE >= 100
   AGE = AGE - 100
ENDIF 
IF AGE < 1
   AGE = 1
ENDIF

** Buu 16/7/04 - Print Date of Birth instead of Age
**@  14, 12  SAY age                                                                                                                                                                                                                                        
@  12, 12  SAY dobpat                                                                                                                                                                                                                                        
** Buu 16/7/04 - End

** 7/12/99 - Dickson - Print out the Company name and VAT Tax code
** 15/10/2009 - Thien - Do not print out the Comp Name when 'NO RECORDED COMPANY'
IF RTRIM(M_JOBCORP) <> 'NO RECORDED COMPANY'
@  13, 16 say RTRIM(M_JOBCORP)
ENDIF
*@  16, 19 say RTRIM(M_JOBCORP) + '  '+RTRIM(M_JOBADD1)
@  14, 42  SAY NATIO
@  14, 70  SAY ISEX
@  15, 16 say RTRIM(M_JOBADD1)

** Buu - Print Paymode is credit for outstd, directb, ccp
if paymode='OUTSTD' .OR. paymode='CCP' .OR. paymode='DIRECTB' .OR. paymode='DIRECT'
	xpaymode='CREDIT'
	** Print Credit if paymode is 'OUTSTD'
	if paymode='OUTSTD'
		@  17, 19 say xpaymode
		@  17, 40 say RTRIM(M_JOBTEL3)
	endif
	if paymode='CCP' 
		@  17, 19 say xpaymode
		@  17, 40 say RTRIM(M_JOBTEL3)
		@  18, 19 say '('+paymode+')'
	endif
	if paymode='DIRECTB' .OR. paymode='DIRECT'
		@  17, 19 say xpaymode
		@  17, 40 say RTRIM(M_JOBTEL3)
		@  18, 3 say '('+payon+')'
		@  18, 19 say '('+paymode+')'
	endif
else
	@  17, 19 say paymode
	@  17, 40 say RTRIM(M_JOBTEL3)
endif
** Buu - End

Procedure DECL_MD                                                                                                                                                                                                                                         
*-----------------                                                                                                                                                                                                                                        
@ 56,10 SAY RTRIM(FNMPAT)+' '+NMPAT                                                                                                                                                                                                                       
@ 57,59 SAY subs(dtoc(DATE()),1,2)                                                                                                                                                                                                                        
@ 57,62 SAY subs(dtoc(DATE()),4,2)                                                                                                                                                                                                                        
@ 57,65 SAY subs(dtoc(DATE()),7,4)                                                                                                                                                                                                                        
																															  
Procedure DECL_DATE                                                                                                                                                                                                                                       
*-----------------                                                                                                                                                                                                                                        
@ 65,10 SAY subs(dtoc(DATE()),1,2)                                                                                                                                                                                                                        
@ 65,13 SAY subs(dtoc(DATE()),4,2)                                                                                                                                                                                                                        
@ 65,16 SAY subs(dtoc(DATE()),7,4)                                                                                                                                                                                                                        
																															  
																															  
Procedure EjectLA                                                                                                                                                                                                                                         
*--------------                                                                                                                                                                                                                                           
prow = prow()                                                                                                                                                                                                                                             
skip_line = 66 - prow                                                                                                                                                                                                                                     
SET CONSOLE OFF                                                                                                                                                                                                                                           
For i = 1 to skip_line                                                                                                                                                                                                                                    
    ?                                                                                                                                                                                                                                                     
next i                                                                                                                                                                                                                                                    
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
SET CONSOLE ON                                                                                                                                                                                                                                            
setprc(0,0)                                                                                                                                                                                                                                               
																															  
Procedure Eject                                                                                                                                                                                                                                           
*--------------                                                                                                                                                                                                                                           
prow = prow()                                                                                                                                                                                                                                             
skip_line = 66 - prow                                                                                                                                                                                                                                     
SET CONSOLE OFF                                                                                                                                                                                                                                           
For i = 1 to skip_line                                                                                                                                                                                                                                    
    ?                                                                                                                                                                                                                                                     
next i                                                                                                                                                                                                                                                    
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
?                                                                                                                                                                                                                                                         
SET CONSOLE ON                                                                                                                                                                                                                                            
setprc(0,0)                                                                                                                                                                                                                                               
